// pages/cardList/cardList.js  
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabArr: {
      curHdIndex: 0,
      curBdIndex: 0,
      sendnum:0,
      resivenum:0,
      sendlist:[],
      resivelist:[]
    },
  },
  todetail:function(e){
    wx.navigateTo({
      url: '/pages/resivecardinfo/resivecardinfo?cardid='+e.currentTarget.dataset.id,
    })
  },
  tabFun: function (e) {
    //获取触发事件组件的dataset属性 
    var _datasetId = e.target.dataset.id;
    var _obj = {};
    _obj.curHdIndex = _datasetId;
    _obj.curBdIndex = _datasetId;
    this.setData({
      tabArr: _obj
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var _datasetId = options.index || 0;
    var _obj = {};
    _obj.curHdIndex = _datasetId;
    _obj.curBdIndex = _datasetId;
    this.setData({
      tabArr: _obj
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    wx.showLoading({
      title: '数据加载中',
    })
    var that = this;
    var userinfo = wx.getStorageSync('userinfo')
    wx.request({
      url: app.siteinfo.rootpath + 'myhk',
      method: "post",
      data: {
        id: wx.getStorageSync('user_id')
      },
      success: function (res) {
        if (res.data.code == 200) {
          that.setData({
            logo: userinfo.logo,
            sendnum: res.data.sendtotalnum,
            resivenum: res.data.resivetotalnum,
            resivelist: res.data.resivelist,
            sendlist: res.data.sendlist,
          })
        } else {
          wx.showToast({
            title: '信息获取失败',
            icon: "none"
          })
        }
      },
      complete: function () {
        wx.hideLoading()
      }
    })
  },
  carddetail:function(e){
    var that = this;
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/preview/preview?id='+id + '&is_received=1',
    })
  },  
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})